import React, { Component } from 'react'
import { withStyles } from 'material-ui/styles'
import AdminBar from '../components/admin/AdminBar'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { ActionCreators } from '../actions'

const styles = theme => ({
	root: {

	}
})

@connect(mapStateToProps, mapDispatchToProps)
@withStyles(styles)
class AdminContainer extends Component {
	constructor(props) {
	  super(props);
	}

	render() {
		const { classes, isAuthed } = this.props
		if(!isAuthed) {
			return (
				<div>请登录!</div>
			)
		}
		return (
			<div className={classes.root}>
				<AdminBar {...this.props} />
			</div>
		)
	}
}

function mapStateToProps(state) {
	return {
		isAuthed: state.auth.isAuthed
	}
}

function mapDispatchToProps( dispatch ){
	return bindActionCreators( ActionCreators, dispatch)
}

export default AdminContainer